package com.hao.crawler;

import com.hao.crawler.parse.Parse;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

/**
 * Dom爬虫
 * Created by R.hao on 2017/8/8.
 */
public class DomCrawler implements Crawler {

    @Override
    public Elements run(String url) throws Exception {
        Document page = Jsoup.connect(url).get();
        return Parse.doc(page, doc -> {
            Element element = doc.getElementById("big-pic");
            return element.getElementsByTag("img");
        });
    }
}
